﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Insurance.ReadCard
{
    /// <summary>
    /// 电子凭证信息封装
    /// </summary>
    public class DzpzInfo
    {
        /// <summary>
        /// 用户姓名
        /// </summary>
        private string patName;

        public string PatName
        {
            get { return patName; }
            set { patName = value; }
        }

        /// <summary>
        /// 证件号码
        /// </summary>
        private string idNo;

        public string IdNo
        {
            get { return idNo; }
            set { idNo = value; }
        }

        /// <summary>
        /// 证件类型
        /// </summary>
        private string idType;

        public string IdType
        {
            get { return idType; }
            set { idType = value; }
        }

        /// <summary>
        /// 令牌
        /// </summary>
        private string token;

        public string Token
        {
            get { return token; }
            set { token = value; }
        }

        /// <summary>
        /// 参保地行政区划
        /// </summary>
        private string insuArea;

        public string InsuArea
        {
            get { return insuArea; }
            set { insuArea = value; }
        }

        /// <summary>
        /// 参数
        /// </summary>
        private string dzpzStr;

        public string DzpzStr
        {
            get { return dzpzStr; }
            set { dzpzStr = value; }
        }

        private string _SplitStr = "|";

        public DzpzInfo(string _dzpzStr)
        {
            dzpzStr = _dzpzStr.Replace("\u0000", "").Trim().TrimEnd('|');
            try
            {
                string[] s = dzpzStr.Split(new string[] { _SplitStr }, StringSplitOptions.None);
                int p = 0;
                patName = s[p++];
                idNo = s[p++];
                idType = s[p++];
                token = s[p++];
                insuArea = s[p++];
            }
            catch (Exception ee)
            {
                Exception ex = new Exception("分解电子凭证返回串错误[" + _dzpzStr + "]", ee);
                throw ex;
            }
        }

        public string getQgyktIcStr()
        {
            return patName + _SplitStr + idType + _SplitStr + idNo + _SplitStr + token;
        }
    }
}